home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / mus / play / tracker_4_31.lzh / tracker / setup_audio.c < prev    next >
C/C++ Source or Header  |  1995-05-11  |  2KB  |  105 lines

  1. /* setup_audio.c 
  2.     vi:ts=3 sw=3:
  3.  */
  4. /* higher level interface to the raw metal */
  5.  
  6. /* $Id: setup_audio.c,v 4.13 1995/05/11 12:26:22 espie Exp espie $
  7.  * $Log: setup_audio.c,v $
  8.  * Revision 4.13  1995/05/11  12:26:22  espie
  9.  * Corrected types.
  10.  *
  11.  * Revision 4.12  1995/02/21  21:13:16  espie
  12.  * Cleaned up source. Moved minor pieces of code around.
  13.  *
  14.  * Revision 4.11  1995/02/21  17:54:32  espie
  15.  * Internal problem: buggy RCS. Fixed logs.
  16.  *
  17.  * Revision 4.0  1994/01/11  17:55:28  espie
  18.  * Use autoinit.
  19.  * Suppressed multiple at_end.
  20.  * Use new pref scheme.
  21.  * Modified in a more consistent way.
  22.  * Added check before closing for the sgi.
  23.  * Added finetune.
  24.  */
  25.  
  26.  
  27.  
  28. #include "defs.h"
  29. #include "extern.h"
  30. #include "tags.h"
  31. #include "prefs.h"
  32.  
  33. ID("$Id: setup_audio.c,v 4.13 1995/05/11 12:26:22 espie Exp espie $")
  34.  
  35. LOCAL void init_audio P((void));
  36.  
  37. LOCAL void (*INIT)P((void)) = init_audio;
  38.  
  39. LOCAL int opened = FALSE;
  40. LOCAL int ask_freq, real_freq, oversample;
  41. LOCAL int stereo;
  42.  
  43.  
  44. /* forward declaration */
  45. LOCAL void do_close_audio P((void));
  46.  
  47. LOCAL void init_audio()
  48.    {
  49.    at_end(do_close_audio);
  50.    }
  51.  
  52. /* setup_audio(frequency, stereo, oversample):
  53.  * try to avoid calling open_audio and other things
  54.  * all the time
  55.  */
  56. void setup_audio(f, s, o)
  57. int f;
  58. int s;
  59. int o;
  60.    {
  61.    INIT_ONCE;
  62.  
  63.    if (!opened)
  64.       {
  65.       ask_freq = f;
  66.       stereo = s;
  67.       oversample = o;
  68.       real_freq = open_audio(f, s);
  69.       init_player(o, real_freq);
  70.       opened = TRUE;
  71.       }
  72.    else
  73.       {
  74.       int new_freq;
  75.  
  76.       if (s != stereo || f != ask_freq)
  77.          {
  78.          ask_freq = f;
  79.          stereo = s;
  80.          close_audio();
  81.          new_freq = open_audio(f, s);
  82.          }
  83.       else
  84.          new_freq = real_freq;
  85.  
  86.       if (new_freq != real_freq || oversample != o)
  87.          {
  88.          real_freq = new_freq;
  89.          oversample = o;
  90.          init_player(o, real_freq);
  91.          }
  92.       }
  93.    set_synchro(get_pref_scalar(PREF_SYNC));
  94.    }
  95.  
  96. LOCAL void do_close_audio()
  97.    {
  98.    if (opened)
  99.       {
  100.       close_audio();
  101.       }
  102.    opened = FALSE;
  103.    }
  104.  
  105.